home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / integer.Z / integer
Encoding:
Text File  |  1998-10-28  |  1.4 KB  |  67 lines

  1.  
  2.  
  3.  
  4.      iiiinnnntttteeeeggggeeeerrrr((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))        iiiinnnntttteeeeggggeeeerrrr((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       integer - Perl pragma    to compute arithmetic in integer
  10.       instead of double
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.           use integer;
  14.           $x = 10/3;
  15.           #    $x is now 3, not 3.33333333333333333
  16.  
  17.  
  18.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  19.       This tells the compiler to use integer operations from here
  20.       to the end of    the enclosing BLOCK.  On many machines,    this
  21.       doesn't matter a great deal for most computations, but on
  22.       those    without    floating point hardware, it can    make a big
  23.       difference.
  24.  
  25.       Note that this affects the operations, not the numbers.  If
  26.       you run this code
  27.  
  28.           use integer;
  29.           $x = 1.5;
  30.           $y = $x +    1;
  31.           $z = -1.5;
  32.  
  33.       you'll be left with $x == 1.5, $y == 2 and $z    == -1.    The $z
  34.       case happens because unary - counts as an operation.
  35.  
  36.       See the section on _P_r_a_g_m_a_t_i_c _M_o_d_u_l_e_s in the _p_e_r_l_m_o_d manpage.
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.